package com.aeye.mbr.upms.client.controller;

import com.aeye.mbr.common.exception.TalkeduException;
import com.aeye.mbr.common.result.ApiResult;
import com.aeye.mbr.upms.dao.model.UpmsUser;

import javax.servlet.http.HttpServletRequest;

public abstract class BaseManageController {


    protected UpmsUser getUpmsUser(HttpServletRequest request) {
        UpmsUser upmsUser = (UpmsUser) request.getAttribute("upmsUser");
        return upmsUser;
    }


    protected ApiResult handleException(Exception e) {
        if (e instanceof TalkeduException) {
            TalkeduException te = (TalkeduException) e;
            return ApiResult.buildError(te.getCode(), te.getMsg());
        }
        return ApiResult.buildInternalError("未知错误!");
    }
}
